from LongUI.page.login_page import LoginPage
from selenium.webdriver.common.by import By

class UserPage(LoginPage):
    # 断言系统菜单
    dy1_loc = By.XPATH, '//*[@id="sidebar"]/div[1]/h2'
    def dy1(self):
        return self.text(self.dy1_loc)

    # 点击用户管理
    user_loc=By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[5]/h2'
    def user(self):
        self.click(self.user_loc)

    # 点击用户信息
    userinformation_loc=By.XPATH,'//*[@id="sidebar"]/div[2]/div[6]/ul/li/div/a'
    def userinformation(self):
        self.click(self.userinformation_loc)

    # 点击添加用户
    adduser_loc=By.XPATH,'//*[@id="navTab"]/div[2]/div[2]/div[2]/div[1]/ul/li[1]/a/span'
    def adduser(self):
        self.click(self.adduser_loc)

    # 输入用户名称
    name_loc=By.NAME,'userName'
    def name(self):
        self.send_keys(self.name_loc,'二组测试')

    # 输入手机号
    mobile_loc=By.NAME,'mobile'
    def mobile(self):
        self.send_keys(self.mobile_loc,'21345678900')

    # 输入登录密码
    password_loc=By.NAME,'password'
    def password(self):
        self.send_keys(self.password_loc,'1Q!a2')

    def userpage(self):
        self.longguo_login()
        print(self.dy1())
        assert '系统菜单' == self.dy1()
        self.user()
        self.userinformation()
        self.adduser()
        self.name()
        self.mobile()
        self.password()